//老师详情页标签切换
function selectTags(tagid, showContent,selfObj){
    // 操作标签
    var tag = document.getElementById(tagid).getElementsByTagName("li");
    var taglength = tag.length;

    for(i=0; i<taglength; i++){
            $("#tab"+i).attr('class','');
    }
    selfObj.className = "on";
    // 操作内容
    for(i=0; j=document.getElementById("tagContents"+i); i++){
            j.style.display = "none";
    }
    $("#"+showContent).show();
};

//老师详情页评论列表
function commentShow (id) {
	$.ajax({
		url :'/teacher/commentlist/' +id,
		type:'get',
		dataType:'html',
    	success: function (msg) {
    		$("#CommentsList").html(msg);
    	}
	})
};

//发表对老师的评论
function commentAdd(id) {
    var title = $("#title").val();
    var content = $("#content").val();
    if ($.trim(title) == ''){
        alert("请填写评论标题！");
		return false;
    }
    if ($.trim(content) == '') {
        alert("请填写评论内容！");
        return false;
    }else{
    	$.ajax({
    		url :'/teacher/commentadd/' +id+ '/' +title+ '/' +content,
    		type:'get',
    		dataType:'html',
    		success: function (msg) {
    			if(msg == 1){
                    alert("评论成功！");
    				commentShow(id);
    				return true;
    			}
    			if(msg == 2){
    				alert("评论失败！");
    				return false;
    			}
    			if(msg == 3){
    				alert("您尚未登录，不能发表评论！");
    				$("#username").focus();
    				return false;
    			}
    		}
    	})
    }
};
